package com.jadobo.xswing.attrib;

import java.util.HashMap;
import java.util.Map;

import com.jadobo.xswing.model.Font;
import com.jadobo.xswing.model.Font.FontStyle;
import com.jadobo.xswing.model.Style;

public class DefaultStyle {

	private Map<HtmlElementTag, IStyle> map = new HashMap<HtmlElementTag, IStyle>();
	
	public DefaultStyle() {
		
		for(HtmlElementTag tag : HtmlElementTag.values()) {
			Style style = new Style();
			map.put(tag, style);
		}
		
		
		initFont(HtmlElementTag.h1, "serif", 32);
		initFont(HtmlElementTag.h2, "serif", 24);
		initFont(HtmlElementTag.h3, "serif", 18);
		initFont(HtmlElementTag.h4, "serif", 16);
		initFont(HtmlElementTag.h5, "serif", 13);
		initFont(HtmlElementTag.h6, "serif", 10);
		
	}
	
	private void initFont(HtmlElementTag elem, String name, int size) {
		
		Style style = (Style) map.get(elem);
		Font font = new Font();
		font.setFont(name);
		font.setSize(size);
		font.setFontStyle(FontStyle.normal);
		style.setFont(font);
		
	}

	public IStyle getStyle(HtmlElementTag tag) {
		return map.get(tag);
	}
	
}
